﻿//-----------------------------------------------------------------------
// <copyright file="HasUnencapsulatedConditional.cs" company="None">
//     Copyright (c) 2009-2012
// </copyright>
//-----------------------------------------------------------------------

namespace CleanCode.StyleCopCustomRules.UnitTests.Resources
{
    using System;

    /// <summary>
    /// Dummy class to unit test the customized StyleCop rules.
    /// </summary>
    public class HasUnencapsulatedConditional
    {
        /// <summary>
        /// Dummy field holding the exptected value.
        /// </summary>
        private string expected = "e";

        /// <summary>
        /// Dummy field holding the actual value.
        /// </summary>
        private string actual = "a";

        /// <summary>
        /// Methods the containing not encapsulated conditional.
        /// </summary>
        public void MethodContainingUnencapsulatedConditional()
        {
            if (this.AreStringsEqual())
            {
                Console.WriteLine("Shouln't raise a violation.");
            }

            if (this.expected == null || this.actual == null || this.AreStringsEqual())
            {
                Console.WriteLine("Dumm text for conditional.");
            }
        }

        /// <summary>
        /// Ares the strings equal.
        /// </summary>
        /// <returns>
        /// Returns true if expected and actual are equal, false otherwise.
        /// </returns>
        private bool AreStringsEqual()
        {
            return this.expected == this.actual;
        }

        /// <summary>
        /// Determines whether to compact or not (example code from the book).
        /// </summary>
        /// <returns>
        /// Returns true if it should compact, false otherwise.
        /// </returns>
        private bool ShouldNotCompact()
        {
            return this.expected == null || this.actual == null || this.AreStringsEqual();
        }
    }
}
